package self.niu.com.resume.db.dbHeple;


import java.util.List;

import self.niu.com.resume.AppBase;
import self.niu.com.resume.db.DaoFactory;
import self.niu.com.resume.db.JavaAbility;
import self.niu.com.resume.db.KnowAbility;
import self.niu.com.resume.db.Projects;
import self.niu.com.resume.db.SeniorAbility;
import self.niu.com.resume.db.SkilledAbility;
import self.niu.com.resume.db.ToolsAbility;
import self.niu.com.resume.db.User;

public class DbHander {
    private static DbHander hander;

    private DbHander() {
        AppBase.initDbconfig();
        DaoFactory.getUserDao().createDb(User.class);
        DaoFactory.getJavaAbilityDao().createDb(JavaAbility.class);
    }

    public static DbHander getInstance() {
        if (hander == null) {
            hander = new DbHander();
        }
        return hander;
    }

    //添加用户
    public void addUser(String id, String title, String content, String url) {
        DaoFactory.getUserDao().save(new User(id, title, content, url));
    }

    //查找所有的信息
    public List<User> findUserAll() {
        return DaoFactory.getUserDao().findAll();
    }

    //修改信息
    public void upData(User user, String numberCusor) {
        DaoFactory.getUserDao().update(user, numberCusor);
    }

    //添加java
    public void addJavaAbility(String content, int imagurl, String detail, String weburl) {
        DaoFactory.getJavaAbilityDao().save(new JavaAbility(content, imagurl, detail, weburl));
    }

    //查找所有的信息
    public List<JavaAbility> findJavaAbilityAll() {
        return DaoFactory.getJavaAbilityDao().findAll();
    }

    //修改信息
    public void upData(JavaAbility user, String numberCusor) {
        DaoFactory.getJavaAbilityDao().update(user, numberCusor);
    }

    //添加know
    public void addKnowAbility(String content, int imagurl, String detail, String weburl) {
        DaoFactory.getKnowAbilityDao().save(new KnowAbility(content, imagurl, detail, weburl));
    }

    //查找所有know的信息
    public List<KnowAbility> findKnowAbilityAll() {
        return DaoFactory.getKnowAbilityDao().findAll();
    }

    //修改know信息
    public void upData(KnowAbility konw, String numberCusor) {
        DaoFactory.getKnowAbilityDao().update(konw, numberCusor);
    }


    //添加senior
    public void addSeniorAbility(String content, int imagurl, String detail, String weburl) {
        DaoFactory.getSeniorAbilityDao().save(new SeniorAbility(content, imagurl, detail, weburl));
    }

    //查找所有senior的信息
    public List<SeniorAbility> findSeniorAbilityAll() {
        return DaoFactory.getSeniorAbilityDao().findAll();
    }

    //修改senior信息
    public void upData(SeniorAbility senior, String numberCusor) {
        DaoFactory.getSeniorAbilityDao().update(senior, numberCusor);
    }

    //添加skilled
    public void addSkilledAbility(String content, int imagurl, String detail, String weburl) {
        DaoFactory.getSkilledAbilityDao().save(new SkilledAbility(content, imagurl, detail, weburl));
    }

    //查找所有skilled的信息
    public List<SkilledAbility> findSkilledAbilityAll() {
        return DaoFactory.getSkilledAbilityDao().findAll();
    }

    //修改skilled信息
    public void upData(SkilledAbility skilled, String numberCusor) {
        DaoFactory.getSkilledAbilityDao().update(skilled, numberCusor);
    }

    //添加tool
    public void addToolAbility(String content, int imagurl, String detail, String weburl) {
        DaoFactory.getToolAbilityDao().save(new ToolsAbility(content, imagurl, detail, weburl));
    }

    //查找所有tool的信息
    public List<ToolsAbility> findToolAbilityAll() {
        return DaoFactory.getToolAbilityDao().findAll();
    }

    //修改tool信息
    public void upData(ToolsAbility tool, String numberCusor) {
        DaoFactory.getToolAbilityDao().update(tool, numberCusor);
    }

    //添加projects
    public void addProjects(String proName, String proTime, String proTool, String proSummary, String proDuty, String proTechnic, String proImageid) {
        DaoFactory.getProjectsDao().save(new Projects(proName, proTime, proTool, proSummary, proDuty, proTechnic, proImageid));
    }

    //查找所有projects的信息
    public List<Projects> findProjectAll() {
        return DaoFactory.getProjectsDao().findAll();
    }

    //修改projects信息
    public void upData(Projects pro, String numberCusor) {
        DaoFactory.getProjectsDao().update(pro, numberCusor);
    }
}

